package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.entity.Teacher;
import com.example.demo.mapper.TeacherMapper;
import com.example.demo.service.ITeacherService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.utils.AjaxJson;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 教师信息表 服务实现类
 * </p>
 *
 * @author 
 * @since 2025-11-10
 */
@Service
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> implements ITeacherService {

    @Override
    public AjaxJson deleteByTeacherNo(String teacherNo) {
        return this.baseMapper.delete(new QueryWrapper<Teacher>().eq("teacher_no", teacherNo))>=1?AjaxJson.getSuccess("删除成功"):AjaxJson.getError("删除失败");
    }

    @Override
    public Teacher listByTeacherNo(String teacherNo) {
        return this.baseMapper.selectOne(new QueryWrapper<Teacher>().eq("teacher_no", teacherNo));
    }

    @Override
    public Teacher getByUserId(Integer userId) {
        return this.baseMapper.selectOne(new QueryWrapper<Teacher>().eq("user_id", userId));
    }
}
